Drop key themes
authorMatthias Clasen <mclasen@redhat.com>
Thu, 21 Feb 2019 05:58:30 +0000 (00:58 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 21 Feb 2019 17:22:50 +0000 (12:22 -0500)
These were an abuse of css, and not very successful
as a concept. We are going to replace bindings with
a new way of doing customizable shortcuts.

gtk/gtk-keys.css.default [deleted file]
gtk/gtk-keys.css.emacs [deleted file]
gtk/gtk-keys.css.mac [deleted file]
gtk/gtkcssprovider.c
gtk/gtksettings.c
gtk/meson.build

diff --git a/gtk/gtk-keys.css.default b/gtk/gtk-keys.css.default
deleted file mode 100644 (file)
index 5982804..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * Default keybinding set. Empty because it is implemented inline in the code.
- */
diff --git a/gtk/gtk-keys.css.emacs b/gtk/gtk-keys.css.emacs
deleted file mode 100644 (file)
index 6639e8d..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 2002 Owen Taylor
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * A keybinding set implementing Emacs-like keybindings
- */
-
-/*
- * Bindings for GtkTextView and GtkEntry
- */
-@binding-set gtk-emacs-text-entry
-{
-  bind "<ctrl>b" { "move-cursor" (logical-positions, -1, 0) };
-  bind "<shift><ctrl>b" { "move-cursor" (logical-positions, -1, 1) };
-  bind "<ctrl>f" { "move-cursor" (logical-positions, 1, 0) };
-  bind "<shift><ctrl>f" { "move-cursor" (logical-positions, 1, 1) };
-
-  bind "<alt>b" { "move-cursor" (words, -1, 0) };
-  bind "<shift><alt>b" { "move-cursor" (words, -1, 1) };
-  bind "<alt>f" { "move-cursor" (words, 1, 0) };
-  bind "<shift><alt>f" { "move-cursor" (words, 1, 1) };
-
-  bind "<ctrl>a" { "move-cursor" (paragraph-ends, -1, 0) };
-  bind "<shift><ctrl>a" { "move-cursor" (paragraph-ends, -1, 1) };
-  bind "<ctrl>e" { "move-cursor" (paragraph-ends, 1, 0) };
-  bind "<shift><ctrl>e" { "move-cursor" (paragraph-ends, 1, 1) };
-
-  bind "<ctrl>w" { "cut-clipboard" () };
-  bind "<ctrl>y" { "paste-clipboard" () };
-
-  bind "<ctrl>d" { "delete-from-cursor" (chars, 1) };
-  bind "<alt>d" { "delete-from-cursor" (word-ends, 1) };
-  bind "<ctrl>k" { "delete-from-cursor" (paragraph-ends, 1) };
-  bind "<alt>backslash" { "delete-from-cursor" (whitespace, 1) };
-
-  bind "<alt>space" { "delete-from-cursor" (whitespace, 1)
-                      "insert-at-cursor" (" ") };
-  bind "<alt>KP_Space" { "delete-from-cursor" (whitespace, 1)
-                         "insert-at-cursor" (" ")  };
-  bind "<alt>BackSpace" { "delete-from-cursor" (word-ends, -1) };
-  /*
-   * Some non-Emacs keybindings people are attached to
-   */
-  bind "<ctrl>u" { "move-cursor" (paragraph-ends, -1, 0)
-                   "delete-from-cursor" (paragraph-ends, 1) };
-
-  bind "<ctrl>h" { "delete-from-cursor" (chars, -1) };
-  bind "<ctrl>w" { "delete-from-cursor" (word-ends, -1) };
-}
-
-/*
- * Bindings for GtkTextView
- */
-@binding-set gtk-emacs-text-view
-{
-  bind "<ctrl>p" { "move-cursor" (display-lines, -1, 0) };
-  bind "<shift><ctrl>p" { "move-cursor" (display-lines, -1, 1) };
-  bind "<ctrl>n" { "move-cursor" (display-lines, 1, 0) };
-  bind "<shift><ctrl>n" { "move-cursor" (display-lines, 1, 1) };
-
-  bind "<ctrl>space" { "set-anchor" () };
-  bind "<ctrl>KP_Space" { "set-anchor" () };
-}
-
-/*
- * Bindings for GtkTreeView
- */
-@binding-set gtk-emacs-tree-view
-{
-  bind "<ctrl>s" { "start-interactive-search" () };
-  bind "<ctrl>f" { "move-cursor" (logical-positions, 1) };
-  bind "<ctrl>b" { "move-cursor" (logical-positions, -1) };
-}
-
-/*
- * Bindings for menus
- */
-@binding-set gtk-emacs-menu
-{
-  bind "<ctrl>n" { "move-current" (next) };
-  bind "<ctrl>p" { "move-current" (prev) };
-  bind "<ctrl>f" { "move-current" (child) };
-  bind "<ctrl>b" { "move-current" (parent) };
-}
-
-entry {
-  -gtk-key-bindings: gtk-emacs-text-entry;
-}
-
-textview {
-  -gtk-key-bindings: gtk-emacs-text-entry, gtk-emacs-text-view;
-}
-
-treeview {
-  -gtk-key-bindings: gtk-emacs-tree-view;
-}
-
-GtkMenuShell {
-  -gtk-key-bindings: gtk-emacs-menu;
-}
diff --git a/gtk/gtk-keys.css.mac b/gtk/gtk-keys.css.mac
deleted file mode 100644 (file)
index e085356..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-@binding-set gtk-mac-alt-arrows
-{
-  bind "<alt>Right"           { "move-cursor" (words, 1, 0) };
-  bind "<alt>KP_Right"        { "move-cursor" (words, 1, 0) };
-  bind "<alt>Left"            { "move-cursor" (words, -1, 0) };
-  bind "<alt>KP_Left"         { "move-cursor" (words, -1, 0) };
-  bind "<shift><alt>Right"    { "move-cursor" (words, 1, 1) };
-  bind "<shift><alt>KP_Right" { "move-cursor" (words, 1, 1) };
-  bind "<shift><alt>Left"     { "move-cursor" (words, -1, 1) };
-  bind "<shift><alt>KP_Left"  { "move-cursor" (words, -1, 1) };
-}
-
-@binding-set gtk-mac-alt-delete
-{
-  bind "<alt>Delete" { "delete-from-cursor" (word-ends, 1) };
-  bind "<alt>KP_Delete" { "delete-from-cursor" (word-ends, 1) };
-  bind "<alt>BackSpace" { "delete-from-cursor" (word-ends, -1) };
-}
-
-@binding-set gtk-mac-cmd-c
-{
-  bind "<meta>x" { "cut-clipboard" () };
-  bind "<meta>c" { "copy-clipboard" () };
-  bind "<meta>v" { "paste-clipboard" () };
-  unbind "<ctrl>x";
-  unbind "<ctrl>c";
-  unbind "<ctrl>v";
-}
-
-@binding-set gtk-mac-text-view
-{
-  bind "<shift><meta>a" { "select-all" (0) };
-  bind "<meta>a" { "select-all" (1) };
-  unbind "<shift><ctrl>a";
-  unbind "<ctrl>a";
-}
-
-@binding-set gtk-mac-label
-{
-  bind "<meta>a" {
-    "move-cursor" (paragraph-ends, -1, 0)
-    "move-cursor" (paragraph-ends, 1, 1)
-  };
-  bind "<shift><meta>a" { "move-cursor" (paragraph-ends, 0, 0) };
-  bind "<meta>c" { "copy-clipboard" () };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-  unbind "<ctrl>c";
-}
-
-@binding-set gtk-mac-entry
-{
-  bind "<meta>a" {
-    "move-cursor" (buffer-ends, -1, 0)
-    "move-cursor" (buffer-ends, 1, 1)
-  };
-  bind "<shift><meta>a" { "move-cursor" (visual-positions, 0, 0) };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-}
-
-@binding-set gtk-mac-file-chooser
-{
-  bind "<meta>v" { "location-popup-on-paste" () };
-  unbind "<ctrl>v";
-
-  bind "<meta><shift>G" { "location-popup" () };
-  bind "<meta><shift>H" { "home-folder" () };
-  bind "<meta>Up" { "up-folder" () };
-}
-
-@binding-set gtk-mac-tree-view
-{
-  bind "<meta>a" { "select-all" () };
-  bind "<shift><meta>a" { "unselect-all" () };
-  bind "<meta>f" { "start-interactive-search" () };
-  bind "<meta>F" { "start-interactive-search" () };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-  unbind "<ctrl>f";
-  unbind "<ctrl>F";
-}
-
-@binding-set gtk-mac-icon-view
-{
-  bind "<meta>a" { "select-all" () };
-  bind "<shift><meta>a" { "unselect-all" () };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-}
-
-@binding-set gtk-mac-alt-arrows
-{
-  bind "<alt>Right"           { "move-cursor" (words, 1, 0) };
-  bind "<alt>KP_Right"        { "move-cursor" (words, 1, 0) };
-  bind "<alt>Left"            { "move-cursor" (words, -1, 0) };
-  bind "<alt>KP_Left"         { "move-cursor" (words, -1, 0) };
-  bind "<shift><alt>Right"    { "move-cursor" (words, 1, 1) };
-  bind "<shift><alt>KP_Right" { "move-cursor" (words, 1, 1) };
-  bind "<shift><alt>Left"     { "move-cursor" (words, -1, 1) };
-  bind "<shift><alt>KP_Left"  { "move-cursor" (words, -1, 1) };
-}
-
-@binding-set gtk-mac-alt-delete
-{
-  bind "<alt>Delete" { "delete-from-cursor" (word-ends, 1) };
-  bind "<alt>KP_Delete" { "delete-from-cursor" (word-ends, 1) };
-  bind "<alt>BackSpace" { "delete-from-cursor" (word-ends, -1) };
-}
-
-@binding-set gtk-mac-cmd-c
-{
-  bind "<meta>x" { "cut-clipboard" () };
-  bind "<meta>c" { "copy-clipboard" () };
-  bind "<meta>v" { "paste-clipboard" () };
-  unbind "<ctrl>x";
-  unbind "<ctrl>c";
-  unbind "<ctrl>v";
-}
-
-@binding-set gtk-mac-text-view
-{
-  bind "<shift><meta>a" { "select-all" (0) };
-  bind "<meta>a" { "select-all" (1) };
-  unbind "<shift><ctrl>a";
-  unbind "<ctrl>a";
-}
-
-@binding-set gtk-mac-label
-{
-  bind "<meta>a" {
-    "move-cursor" (paragraph-ends, -1, 0)
-    "move-cursor" (paragraph-ends, 1, 1)
-  };
-  bind "<shift><meta>a" { "move-cursor" (paragraph-ends, 0, 0) };
-  bind "<meta>c" { "copy-clipboard" () };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-  unbind "<ctrl>c";
-}
-
-@binding-set gtk-mac-entry
-{
-  bind "<meta>a" {
-    "move-cursor" (buffer-ends, -1, 0)
-    "move-cursor" (buffer-ends, 1, 1)
-  };
-  bind "<shift><meta>a" { "move-cursor" (visual-positions, 0, 0) };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-}
-
-@binding-set gtk-mac-file-chooser
-{
-  bind "<meta>v" { "location-popup-on-paste" () };
-  unbind "<ctrl>v";
-
-  bind "<meta><shift>G" { "location-popup" () };
-  bind "<meta><shift>H" { "home-folder" () };
-  bind "<meta>Up" { "up-folder" () };
-}
-
-@binding-set gtk-mac-tree-view
-{
-  bind "<meta>a" { "select-all" () };
-  bind "<shift><meta>a" { "unselect-all" () };
-  bind "<meta>f" { "start-interactive-search" () };
-  bind "<meta>F" { "start-interactive-search" () };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-  unbind "<ctrl>f";
-  unbind "<ctrl>F";
-}
-
-@binding-set gtk-mac-icon-view
-{
-  bind "<meta>a" { "select-all" () };
-  bind "<shift><meta>a" { "unselect-all" () };
-  unbind "<ctrl>a";
-  unbind "<shift><ctrl>a";
-}
-
-iconview {
-  -gtk-key-bindings: gtk-mac-icon-view;
-}
-
-textview {
-  -gtk-key-bindings: gtk-mac-alt-arrows, gtk-mac-alt-delete, gtk-mac-cmd-c, gtk-mac-text-view;
-}
-
-entry {
-  -gtk-key-bindings: gtk-mac-alt-arrows, gtk-mac-alt-delete, gtk-mac-cmd-c, gtk-mac-entry;
-}
-
-label {
-  -gtk-key-bindings: gtk-mac-alt-arrows, gtk-mac-label;
-}
-
-GtkFileChooserWidget {
-  -gtk-key-bindings: gtk-mac-file-chooser;
-}
-
-treeview {
-  -gtk-key-bindings: gtk-mac-tree-view;
-}
index 94b13dd0537c3b581918d32ddaf38cbd8d81ef88..42d792ca50f3c2ff09ac3c0536ba0636bc55ca6e 100644 (file)
@@ -898,114 +898,6 @@ parse_color_definition (GtkCssScanner *scanner)
   return TRUE;
 }
 
-static gboolean
-parse_binding_set (GtkCssScanner *scanner)
-{
-  GtkBindingSet *binding_set;
-  char *name;
-
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_BINDING_SET);
-
-  if (!_gtk_css_parser_try (scanner->parser, "@binding-set", TRUE))
-    {
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_BINDING_SET);
-      return FALSE;
-    }
-
-  name = _gtk_css_parser_try_ident (scanner->parser, TRUE);
-  if (name == NULL)
-    {
-      gtk_css_provider_error_literal (scanner->provider,
-                                      scanner,
-                                      GTK_CSS_PROVIDER_ERROR,
-                                      GTK_CSS_PROVIDER_ERROR_SYNTAX,
-                                      "Expected name for binding set");
-      _gtk_css_parser_resync (scanner->parser, TRUE, 0);
-      goto skip_semicolon;
-    }
-
-  binding_set = gtk_binding_set_find (name);
-  if (!binding_set)
-    {
-      binding_set = gtk_binding_set_new (name);
-      binding_set->parsed = TRUE;
-    }
-  g_free (name);
-
-  if (!_gtk_css_parser_try (scanner->parser, "{", TRUE))
-    {
-      gtk_css_provider_error_literal (scanner->provider,
-                                      scanner,
-                                      GTK_CSS_PROVIDER_ERROR,
-                                      GTK_CSS_PROVIDER_ERROR_SYNTAX,
-                                      "Expected '{' for binding set");
-      _gtk_css_parser_resync (scanner->parser, TRUE, 0);
-      goto skip_semicolon;
-    }
-
-  while (!_gtk_css_parser_is_eof (scanner->parser) &&
-         !_gtk_css_parser_begins_with (scanner->parser, '}'))
-    {
-      name = _gtk_css_parser_read_value (scanner->parser);
-      if (name == NULL)
-        {
-          _gtk_css_parser_resync (scanner->parser, TRUE, '}');
-          continue;
-        }
-
-      if (gtk_binding_entry_add_signal_from_string (binding_set, name) != G_TOKEN_NONE)
-        {
-          gtk_css_provider_error_literal (scanner->provider,
-                                          scanner,
-                                          GTK_CSS_PROVIDER_ERROR,
-                                          GTK_CSS_PROVIDER_ERROR_SYNTAX,
-                                          "Failed to parse binding set.");
-        }
-
-      g_free (name);
-
-      if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
-        {
-          if (!_gtk_css_parser_begins_with (scanner->parser, '}') &&
-              !_gtk_css_parser_is_eof (scanner->parser))
-            {
-              gtk_css_provider_error_literal (scanner->provider,
-                                              scanner,
-                                              GTK_CSS_PROVIDER_ERROR,
-                                              GTK_CSS_PROVIDER_ERROR_SYNTAX,
-                                              "Expected semicolon");
-              _gtk_css_parser_resync (scanner->parser, TRUE, '}');
-            }
-        }
-    }
-
-  if (!_gtk_css_parser_try (scanner->parser, "}", TRUE))
-    {
-      gtk_css_provider_error_literal (scanner->provider,
-                                      scanner,
-                                      GTK_CSS_PROVIDER_ERROR,
-                                      GTK_CSS_PROVIDER_ERROR_SYNTAX,
-                                      "expected '}' after declarations");
-      if (!_gtk_css_parser_is_eof (scanner->parser))
-        _gtk_css_parser_resync (scanner->parser, FALSE, 0);
-    }
-
-skip_semicolon:
-  if (_gtk_css_parser_begins_with (scanner->parser, ';'))
-    {
-      gtk_css_provider_error_literal (scanner->provider,
-                                      scanner,
-                                      GTK_CSS_PROVIDER_ERROR,
-                                      GTK_CSS_PROVIDER_ERROR_DEPRECATED,
-                                      "Nonstandard semicolon at end of binding set");
-      _gtk_css_parser_try (scanner->parser, ";", TRUE);
-    }
-
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_BINDING_SET);
-
-  return TRUE;
-}
-
 static gboolean
 parse_keyframes (GtkCssScanner *scanner)
 {
@@ -1079,8 +971,6 @@ parse_at_keyword (GtkCssScanner *scanner)
     return;
   if (parse_color_definition (scanner))
     return;
-  if (parse_binding_set (scanner))
-    return;
   if (parse_keyframes (scanner))
     return;
 
index 9c9988e22d5370984f33c18fb18be72d088700a5..0b70835bbf84da32c5d3f37ab4624967b7896a14 100644 (file)
@@ -120,7 +120,6 @@ struct _GtkSettingsPrivate
   GdkDisplay *display;
   GSList *style_cascades;
   GtkCssProvider *theme_provider;
-  GtkCssProvider *key_theme_provider;
   gint font_size;
   gboolean font_size_absolute;
   gchar *font_family;
@@ -149,7 +148,6 @@ enum {
   PROP_SPLIT_CURSOR,
   PROP_THEME_NAME,
   PROP_ICON_THEME_NAME,
-  PROP_KEY_THEME_NAME,
   PROP_DND_DRAG_THRESHOLD,
   PROP_FONT_NAME,
   PROP_XFT_ANTIALIAS,
@@ -215,7 +213,6 @@ static void    settings_update_font_options      (GtkSettings           *setting
 static void    settings_update_font_values       (GtkSettings           *settings);
 static gboolean settings_update_fontconfig       (GtkSettings           *settings);
 static void    settings_update_theme             (GtkSettings           *settings);
-static void    settings_update_key_theme         (GtkSettings           *settings);
 static gboolean settings_update_xsetting         (GtkSettings           *settings,
                                                   GParamSpec            *pspec,
                                                   gboolean               force);
@@ -419,15 +416,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                              NULL);
   g_assert (result == PROP_ICON_THEME_NAME);
 
-  result = settings_install_property_parser (class,
-                                             g_param_spec_string ("gtk-key-theme-name",
-                                                                  P_("Key Theme Name"),
-                                                                  P_("Name of key theme to load"),
-                                                                  NULL,
-                                                                  GTK_PARAM_READWRITE),
-                                             NULL);
-  g_assert (result == PROP_KEY_THEME_NAME);
-
   result = settings_install_property_parser (class,
                                              g_param_spec_int ("gtk-dnd-drag-threshold",
                                                                P_("Drag threshold"),
@@ -1040,7 +1028,6 @@ gtk_settings_finalize (GObject *object)
   g_datalist_clear (&priv->queued_settings);
 
   settings_update_provider (priv->display, &priv->theme_provider, NULL);
-  settings_update_provider (priv->display, &priv->key_theme_provider, NULL);
   g_slist_free_full (priv->style_cascades, g_object_unref);
 
   if (priv->font_options)
@@ -1119,7 +1106,6 @@ settings_init_style (GtkSettings *settings)
                                    GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
 
   settings_update_theme (settings);
-  settings_update_key_theme (settings);
 }
 
 static void
@@ -1300,9 +1286,6 @@ gtk_settings_notify (GObject    *object,
       settings_invalidate_style (settings);
       gtk_style_context_reset_widgets (priv->display);
       break;
-    case PROP_KEY_THEME_NAME:
-      settings_update_key_theme (settings);
-      break;
     case PROP_THEME_NAME:
     case PROP_APPLICATION_PREFER_DARK_THEME:
       settings_update_theme (settings);
@@ -2248,24 +2231,6 @@ settings_update_theme (GtkSettings *settings)
   g_free (theme_variant);
 }
 
-static void
-settings_update_key_theme (GtkSettings *settings)
-{
-  GtkSettingsPrivate *priv = settings->priv;
-  GtkCssProvider *provider = NULL;
-  gchar *key_theme_name;
-
-  g_object_get (settings,
-                "gtk-key-theme-name", &key_theme_name,
-                NULL);
-
-  if (key_theme_name && *key_theme_name)
-    provider = gtk_css_provider_get_named (key_theme_name, "keys");
-
-  settings_update_provider (priv->display, &priv->key_theme_provider, provider);
-  g_free (key_theme_name);
-}
-
 const cairo_font_options_t *
 gtk_settings_get_font_options (GtkSettings *settings)
 {
index 2e6c813b4a1321a6cbd4f1d6b01ca6570751caa3..1d9a38d9238c90ec09c13d36f8159764afe0bdbb 100644 (file)
@@ -1099,13 +1099,4 @@ libgtk_dep = declare_dependency(sources: gtk_dep_sources,
                                 link_with: libgtk,
                                 link_args: common_ldflags)
 
-if quartz_enabled
-  # HACK: install_data() doesn't allow installing under a different name (#1487)
-  # FIXME: or maybe just rename it to gtk-keys.css in the src tree?
-  configure_file(input: 'gtk-keys.css.mac',
-                 output: 'gtk-keys.css',
-                 configuration: configuration_data(),
-                 install_dir: join_paths(get_option('datadir'), 'themes/Mac/gtk-4.0'))
-endif
-
 subdir('tools')